import type { BasicTableColumn } from '@/components/table';
import TableFieldType from '@/components/table/src/types/field-type';
import type { FormSchema } from '@/components/form';
import FormFieldType from '@/components/form/src/types/field-type';

export const columns: BasicTableColumn[] = [
  {
    title: 'configId',
    key: 'configId',
    display: false,
    fieldType: TableFieldType.TEXT,
  },
  {
    title: '参数名称',
    key: 'configName',
    fieldType: TableFieldType.TEXT,
  },
  {
    title: '参数键名',
    key: 'configKey',
    fieldType: TableFieldType.TEXT,
  },
  {
    title: '参数键值',
    key: 'configValue',
    display: false,
    fieldType: TableFieldType.TEXT,
  },
  {
    title: '系统内置',
    key: 'configType',
    fieldType: TableFieldType.TAG,
    width: 100,
    align: 'center',
    tagOptions: {
      options: [
        {
          label: '是',
          value: 'Y',
          type: 'success',
        },
        {
          label: '否',
          value: 'N',
          type: 'error',
        },
      ],
    },
  },
  {
    title: 'remark',
    key: 'remark',
    fieldType: TableFieldType.TEXT,
  },
];

export const schemas: FormSchema[] = [
  {
    field: 'configId',
    component: FormFieldType.INPUT,
    label: 'configId',
    display: false,
  },
  {
    field: 'configName',
    component: FormFieldType.INPUT,
    label: '参数名称',
    rules: [{ required: true }],
  },
  {
    field: 'configKey',
    component: FormFieldType.INPUT,
    label: '参数键名',
    rules: [{ required: true }],
  },
  {
    field: 'configValue',
    component: FormFieldType.INPUT,
    label: '参数键值',
    rules: [{ required: true }],
  },
  {
    field: 'configType',
    component: FormFieldType.RADIO_GROUP,
    label: '系统内置',
    componentProps: {
      options: [
        {
          label: '是',
          value: 'Y',
        },
        {
          label: '否',
          value: 'N',
        },
      ],
    },
    defaultValue: 'N',
  },
  {
    field: 'remark',
    component: FormFieldType.INPUT,
    label: '备注',
    componentProps: {
      type: 'textarea',
    },
    giProps: {
      span: 2,
    },
  },
];

export const searchSchemas: FormSchema[] = [
  {
    field: 'configName',
    component: FormFieldType.INPUT,
    label: '参数名称',
  },
  {
    field: 'configKey',
    component: FormFieldType.INPUT,
    label: '参数键名',
  },
  {
    field: 'configType',
    component: FormFieldType.SELECT,
    label: '系统内置',
    componentProps: {
      options: [
        {
          label: '是',
          value: 'Y',
        },
        {
          label: '否',
          value: 'N',
        },
      ],
      valueField: 'value',
    },
  },
];
